export class StringTool {

    /**
     * 拼接url
     * @param e
     */
    public static concatUrl = function (...e: string[]): string {
        if (e.length === 0) {
            return null
        }
        let result = "";
        for (let i = 0; i < e.length; i++) {
            result = result + "/" + StringTool.fixUrlString(e[i])
        }

        return result

    }

    /**
     * 将字符串前后的 / 去掉
     * @param text
     * @private
     */
    private static fixUrlString(text: string): string {

        if (!text) {
            return ''
        }

        if (!text.startsWith('/') && !text.endsWith('/')) {
            return text
        }
        if (text.startsWith('/')) {
            text = text.slice(1);
        }

        if (text.endsWith('/')) {
            text = text.slice(0, text.length - 1);
        }

        return StringTool.fixUrlString(text);

    }

    public static shortTime = function (timeStr=''){
      return timeStr.substring(0,20)
    }
}
